<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Activity
 * *
 * @property $id  自增ID
 * @property $title  活动标题
 * @property $image  封面图
 * @property $content  内容
 * @property $sign_up_start  开始报名时间
 * @property $sign_up_end  结束报名时间
 * @property $activity_time_start  开始活动时间
 * @property $activity_time_end  结束活动时间
 * @property $address  活动地址
 * @property $limit_count  人数限制
 * @property $limit_age  年龄限制
 * @property $cost  活动费用
 * @property $status  状态 0:关闭 1:开启
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
 *
 * @package  App\Models
 * @mixin \Illuminate\Database\Eloquent\Builder
 */
class Activity extends Model
{
    use SoftDeletes;

    protected $table = 'activities';

    protected $fillable = ['id', 'title', 'image', 'content', 'sign_up_start', 'sign_up_end', 'activity_time_start', 'activity_time_end',
        'address', 'limit_count', 'limit_age', 'cost', 'status', 'publisher_uid'];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function activityForm()
    {
        return $this->hasMany(ActivityForm::class, 'activity_id');
    }
}
